#include "transmission.h"

char g_transmission_running_flag = 1;

transmission_server_t transmission_server_create(
    const transmission_type_t type,
    transmission_server_config_t config)
{
    transmission_server_t transmission = NULL;

    switch (type) {
        default:
        case TRANSMISSION_TCP: {
            transmission = tcp_server_create(config);
            if (transmission == NULL) {
                LOG_ERROR("create tcp transmission failed");
                goto TRANSMISSION_CREATE_FAILED;
            }
            break;
        }
    }

TRANSMISSION_CREATE_FAILED:
    transmission_destroy(type, &transmission);
    return NULL;
}

void transmission_server_destroy(const transmission_type_t type,
    transmission_server_t* t)
{
    switch (type) {
        default:
        case TRANSMISSION_TCP: {
            tcp_server_destroy(t);
            break;
        }
    }
}

ret_t transmission_server_start(const transmission_type_t type,
    transmission_server_t server)
{
    switch (type) {
        default:
        case TRANSMISSION_TCP: {
            return tcp_server_start(server);
        }
    }
    return RET_SUCCESS;
}